function [OUT_Symbols] = Symbol_Mapping (IN_Bits,Rate,type)

%*---------------------------------- Symbol_Mapping -----------------------------------------------%
%
%  [OUT_Symbols] = Symbol_Mapping (IN_Bits,Rate,seq)
%
% the function that mapps the input bit sequence (IN_Bits) into corressponging symbol
% number depend on the rate (constellation mapping).
%
% type: if one it will outs the symbols, otherwise will outs the bits
%*---------------------------------------------------------------------------------------------------*%
LUT_Rate_Symbols = [2 3 4 5 6 6];
Data_Rates = [3200 4800 6400 8000 9600 12800];
Rate_Index = find(Data_Rates==Rate);
N_Symbols = LUT_Rate_Symbols(Rate_Index);%#ok
IN_Seq = reshape(IN_Bits,N_Symbols,length(IN_Bits)/N_Symbols).';

if (Rate == 3200)
    IN_Seq_Int = bi2de(IN_Seq);
    %     IN_Seq_Int = bin2dec(num2str(fliplr(IN_Seq)));
    LUT_Symbol = [0 2 6 4];
    OUT_Symbols = LUT_Symbol (IN_Seq_Int+1);
elseif (Rate == 4800)
    IN_Seq_Int = bi2de(IN_Seq);
    %     IN_Seq_Int = bin2dec(num2str(fliplr(IN_Seq)));
    LUT_Symbol = [1 0 2 3 6 7 5 4];
    OUT_Symbols = LUT_Symbol (IN_Seq_Int+1);
else
    OUT_Symbols = bi2de(IN_Seq);
    %     OUT_Symbols = bin2dec(num2str(fliplr(IN_Seq)));
    if type == 1
        OUT_Symbols = OUT_Symbols;
    else
        OUT_Symbols = de2bi(OUT_Symbols);
    end
end

